package com.ruoyi.web.controller.fx;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.fx.FxChina;
import com.ruoyi.system.service.fx.IFxChinaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 全国省市区经纬度Controller
 * 
 * @author ruoyi
 * @date 2024-07-23
 */
@RestController
@RequestMapping("/fx/china")
public class FxChinaController extends BaseController
{
    @Autowired
    private IFxChinaService fxChinaService;

    /**
     * 查询全国省市区经纬度列表
     */
    @GetMapping("/list")
    public TableDataInfo list(FxChina fxChina)
    {
        startPage();
        List<FxChina> list = fxChinaService.selectFxChinaList(fxChina);
        return getDataTable(list);
    }

    /**
     * 导出全国省市区经纬度列表
     */
    @Log(title = "全国省市区经纬度", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FxChina fxChina)
    {
        List<FxChina> list = fxChinaService.selectFxChinaList(fxChina);
        ExcelUtil<FxChina> util = new ExcelUtil<FxChina>(FxChina.class);
        util.exportExcel(response, list, "全国省市区经纬度数据");
    }

    /**
     * 获取全国省市区经纬度详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fxChinaService.selectFxChinaById(id));
    }

    /**
     * 新增全国省市区经纬度
     */
    @Log(title = "全国省市区经纬度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FxChina fxChina)
    {
        return toAjax(fxChinaService.insertFxChina(fxChina));
    }

    /**
     * 修改全国省市区经纬度
     */
    @Log(title = "全国省市区经纬度", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FxChina fxChina)
    {
        return toAjax(fxChinaService.updateFxChina(fxChina));
    }

    /**
     * 删除全国省市区经纬度
     */
    @Log(title = "全国省市区经纬度", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fxChinaService.deleteFxChinaByIds(ids));
    }

    /**
     * 查询全国省市区经纬度列表
     */
    @GetMapping("/listAll")
    public AjaxResult listAll()
    {
        List<FxChina> list = fxChinaService.listAll();
        return success(list);
    }
}
